package command

import "fmt"

type Command interface {
	Execute() error
}

type StartCommand struct {
}

func (s *StartCommand) Execute() error {
	fmt.Println("游戏开始")
	return nil
}

type MoveCommand struct {
	X, Y int
}

func (m *MoveCommand) Execute() error {
	fmt.Printf("向右移动%d,向上移动%d\n", m.X, m.Y)
	return nil
}

type AttackCommand struct {
	Skill string
}

func (a *AttackCommand) Execute() error {
	fmt.Printf("使用技能:%s\n", a.Skill)
	return nil
}

type Commands []Command

func (c *Commands) Execute() error {
	for _, command := range *c {
		if err := command.Execute(); err != nil {
			return err
		}
	}
	return nil
}

func (c *Commands) AddCommand(command ...Command) {
	*c = append(*c, command...)
}
